<?php


namespace app\api\controller;

use app\BaseController;
use app\model\Config as ConfigModel;

class Config extends BaseController
{
    protected $middleware = [
        \app\middleware\ApiChannel::class,
        \app\middleware\ApiUserAuthV2::class => ['except' => ['phoneInfo']],
    ];

    protected function initialize()
    {
        parent::initialize();
    }

    /**
     *  查询全局副标题全局配置
     */
    public function getCouponSubtitle()
    {
        /**
         * @var ConfigModel $config
         */
        $config = ConfigModel::query()->where('type', 'coupon')->where('field', 'brand_subtitle')->cache('coupon_brand_subtitle_cache', 24*3600)->find();
        if (!$config) {
            return fail('后台暂未配置，请联系技术');
        }
        return success('查询成功', ['brand_subtitle' => $config->value]);
    }
}